using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication1.Models.Mapping
{
    public class ShoppingCartItemMap : EntityTypeConfiguration<ShoppingCartItem>
    {
        public ShoppingCartItemMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("ShoppingCartItems");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Quantity).HasColumnName("Quantity");
            this.Property(t => t.Laptop_ID).HasColumnName("Laptop_ID");
            this.Property(t => t.ShoppingCart_ID).HasColumnName("ShoppingCart_ID");

            // Relationships
            this.HasOptional(t => t.Laptop)
                .WithMany(t => t.ShoppingCartItems)
                .HasForeignKey(d => d.Laptop_ID);
            this.HasOptional(t => t.ShoppingCart)
                .WithMany(t => t.ShoppingCartItems)
                .HasForeignKey(d => d.ShoppingCart_ID);

        }
    }
}
